//
//  AppDelegate.swift
//  上海微博
//
//  Created by co on 16/2/22.
//  Copyright © 2016年 王南侠. All rights reserved.
//

import UIKit
import AFNetworking

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        // 设置外观一定要早
        setupAppearance()
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        
        window?.backgroundColor = UIColor.whiteColor()
        
        // 会将控制器的视图添加为 window 的子视图
        window?.rootViewController = MainViewController()
        
        window?.makeKeyAndVisible()
        
        
        return true
    }


}

// MARK: - 设置应用程序外观
extension AppDelegate {
    
    /// 设置AFN
    private func setupAFNnetWorking(){
        
        // 1.设置网络指示器 - 如果 SDWebImage 下图像不会显示！
        AFNetworkActivityIndicatorManager.sharedManager().enabled = true
        
        // 2.设缓存大小 - diskPath: nil 会使用默认的缓存路径
        // AFN 使用默认缓存的路径 MATTT 但是如果图片 太大或者太小 NSURLCache 都不会缓存
        NSURLCache.setSharedURLCache(NSURLCache(memoryCapacity: 4 * 1024 * 1024, diskCapacity: 20 * 1024 * 1024, diskPath: nil))
        
        
    }
    
    /// 设置全局外观，一旦设置全局有效
    private func setupAppearance(){
        UINavigationBar.appearance().tintColor = ZCAppearanceTintColor
        UITabBar.appearance().tintColor = ZCAppearanceTintColor
        
        // 设置导航栏标题字体
        UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: UIFont.systemFontOfSize(17)]

    }
    
}

